var index = {
    layerIndex: -1,
    condition:{}
};

layui.use(['carousel', 'form'], function(){
    var carousel = layui.carousel
        ,form = layui.form;
    //图片轮播
    carousel.render({
        elem: '#carImg'
        ,width: '1200px'
        ,height: '650px'
        ,interval: 5000
    });
    var $ = layui.$, active = {
        set: function(othis){
            var THIS = 'layui-bg-normal'
                ,key = othis.data('key')
                ,options = {};

            othis.css('background-color', '#5FB878').siblings().removeAttr('style');
            options[key] = othis.data('value');
            ins3.reload(options);
        }
    };

    //监听开关
    form.on('switch(autoplay)', function(){
        ins3.reload({
            autoplay: this.checked
        });
    });

    $('.demoSet').on('keyup', function(){
        var value = this.value
            ,options = {};
        if(!/^\d+$/.test(value)) return;

        options[this.name] = value;
        ins3.reload(options);
    });

    //其它示例
    $('.demoTest .layui-btn').on('click', function(){
        var othis = $(this), type = othis.data('type');
        active[type] ? active[type].call(this, othis) : '';
    });
});

/**
 * 通过热门租车
 * @param carId
 */
index.rentThisCar = function (carId) {
    this.layerIndex = layer.open({
        type: 2,
        title: '租车中',
        area: ['800px', '500px'],
        fix: false,
        maxmin: true,
        content: Feng.ctxPath + '/car/car_rent?carId=' + carId
    });
};